//获取实名认证信息
$('.detail').bind('tap', function() {
	getServer('app/member/account', "", function(res) {
		console.log(JSON.stringify(res))
		//				console.log(res.data.code)
		//		$('.allProducts').html(editList(res.data.products))
	});
})
//获取用户信息接口

$('.info').bind('tap', function() {
	getServer('app/userInfo', "", function(res) {
		console.log(JSON.stringify(res))
		//				console.log(res.data.code)
		//		$('.allProducts').html(editList(res.data.products))
	});
})
//获取身份证信息
$('.idcard').bind('tap', function() {
	getServer('app/member/userIdCard', "", function(res) {
		console.log(JSON.stringify(res))
		//				console.log(res.data.code)
		//		$('.allProducts').html(editList(res.data.products))
	});
})

//身份证照片提交
var subdata = {};
//身份证正面
$('.tackPic').eq(0).bind('tap', function() {
	var cmr = plus.camera.getCamera();
	cmr.captureImage(function(p) {
		plus.io.resolveLocalFileSystemURL(p, function(entry) {
			//          alert("真实路径："+entry.fullPath);  
			$('.showImg').eq(0).attr('src', entry.fullPath)
			canvasDataURL(entry.fullPath, {
				quality: 0.1
			}, function(base64Codes) {
				subdata.frontFile = base64Codes;
			});
		}, function(e) {
			alert(e.message);
		});
	}, function(e) {}, {
		filename: "_doc/camera/"
	});
})
$('.tackPic').eq(1).bind('tap', function() {
	var cmr = plus.camera.getCamera();
	cmr.captureImage(function(p) {
		plus.io.resolveLocalFileSystemURL(p, function(entry) {
			//          alert("真实路径："+entry.fullPath);  
			$('.showImg').eq(1).attr('src', entry.fullPath)
			canvasDataURL(entry.fullPath, {
				quality: 0.1
			}, function(base64Codes) {
				subdata.backFile = base64Codes;
			});
		}, function(e) {
			alert(e.message);
		});
	}, function(e) {}, {
		filename: "_doc/camera/"
	});
})

function getImage() {
	var cmr = plus.camera.getCamera();
	cmr.captureImage(function(path) {
		parm = path
	}, function(e) {
		outSet('取消拍照');
	}, {
		filename: '_doc/gallery/',
		index: 1
	});
}

function galleryImg() {
	// 从相册中选择图片
	outSet('从相册中选择图片：');
	plus.gallery.pick(function(path) {

	}, function(e) {
		outSet('取消选择图片');
	}, {
		filter: 'image'
	});
}
//身份证提交
$('.idcardSub').bind('tap', function() {
	if($('#name').val() == "") {
		mui.toast("请输入姓名")
		return
	}
	if($('#idcard').val() == "") {
		mui.toast("请输入身份证号")
		return
	}

	if(!IdentityCodeValid($("#idcard").val())) {
		//		mui.toast("请正确输入身份证号");
		return
	}
	if(subdata.frontFile == undefined || subdata.frontFile == null) {
		mui.toast('请拍摄身份证正面')
		return
	}
	if(subdata.backFile == undefined || subdata.backFile == null) {
		mui.toast('请拍摄身份证背面')
		return
	}
	plus.nativeUI.showWaiting()
	subdata.name = $("#name").val();
	subdata.idcard = $("#idcard").val();
	postServer('/app/member/mxAuth/getIdCardAuth', $.param(subdata), function(res) {
		console.log(JSON.stringify(res))
		//		plus.nativeUI.closeWaiting()
		if(res.data.success) {
			checkAuth(1)
		} else {
			plus.nativeUI.closeWaiting()
			mui.toast(res.message)
			plus.webview.getLaunchWebview().evalJS("activeModel()")
			plus.webview.close(plus.webview.currentWebview())
		}

	}, function(res) {
		console.log(JSON.stringify(res))
		mui.toast(res.message)
	});
})